package cn.zbzcode.hrm.feign.client;

import cn.zbzcode.hrm.feign.fallback.RedisFeignClientFallbackFactory;
import cn.zbzcode.hrm.utils.AjaxResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

//用来调用缓存服务的Feign接口
@FeignClient(value = "cache-server",fallbackFactory = RedisFeignClientFallbackFactory.class)
@Component
public interface RedisFeignClient {

    @RequestMapping(value = "/redis/set",method = RequestMethod.POST)
    AjaxResult set(@RequestParam("key") String key , @RequestParam("value")String value);

    @RequestMapping(value = "/redis/get/{key}",method = RequestMethod.GET)
    AjaxResult get(@PathVariable("key") String key);

    @RequestMapping(value = "/redis/setex",method = RequestMethod.POST)
    AjaxResult setex(@RequestParam("key") String key,
                            @RequestParam("seconds") int seconds ,
                            @RequestParam("value")String value);
}